﻿using Coolzon.UI.Common.Widgets.Properties;
using Coolzon.UI.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace Coolzon.UI.Common.Widgets
{
    public partial class DataTable
    {
        #region XProperty
        private List<DataTableColumn> _Columns;

        [Category("其他")]
        [DisplayName("列")]
        [Description("GridColumns")]
        //[Editor(typeof(XProperty.Editors.XGridColumnEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "Columns", "列")]
        public List<DataTableColumn> Columns
        {
            get { return _Columns; }
            set
            {
                _Columns = value;
                Refresh();
            }
        }
        private Brush _headerBorderBrush = Brushes.Black;
        [Category("表头")]
        [DisplayName("表头边框颜色")]
        [Description("HeaderBorderBrush")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "HeaderBorderBrush", "表头边框颜色")]
        public Brush HeaderBorderBrush
        {
            get
            {
                return _headerBorderBrush;
            }
            set
            {
                _headerBorderBrush = value;
            }
        }
        private Thickness _headerBorderThickness = new Thickness(1);
        [Category("表头")]
        [DisplayName("表头边框大小")]
        [Description("HeaderBorderThickness")]
        //[Editor(typeof(UI.XProperty.Editors.XThicknessEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "HeaderBorderThickness", "表头边框大小")]
        public Thickness HeaderBorderThickness
        {
            get
            {
                return _headerBorderThickness;
            }
            set
            {
                _headerBorderThickness = value;
            }
        }

        private Brush _headerBackground = Brushes.Gray;
        [Category("表头")]
        [DisplayName("表头背景颜色")]
        [Description("HeaderBackground")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "HeaderBackground", "表头背景颜色")]
        public Brush HeaderBackground
        {
            get
            {
                return _headerBackground;
            }
            set
            {
                _headerBackground = value;
            }
        }
        private FontFamily _XHeaderFont;
        [Category("表头")]
        [DisplayName("表头字体")]
        [Description("HeaderFont")]
        //[Editor(typeof(UI.XProperty.Editors.XFontFamilyEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "HeaderFont", "表头字体")]
        public FontFamily XHeaderFont
        {
            get
            {
                return _XHeaderFont;
            }
            set
            {
                _XHeaderFont = value;
                Refresh();
            }
        }
        private FontWeight _XHeaderFontWeight;
        [Category("表头")]
        [DisplayName("表头字体粗细")]
        [Description("HeaderFontWeight")]
        //[Editor(typeof(UI.XProperty.Editors.XFontWeightEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "HeaderFontWeight", "表头字体粗细")]
        public FontWeight XHeaderFontWeight
        {
            get
            {
                return _XHeaderFontWeight;
            }
            set
            {
                _XHeaderFontWeight = value;
                Refresh();
            }
        }
        private double _XHeaderFontSize;
        [Category("表头")]
        [DisplayName("表头字体大小")]
        [Description("HeaderFontSize")]
        //[Editor(typeof(UI.XProperty.Editors.XDoubleEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "HeaderFontSize", "表头字体大小")]
        public double XHeaderFontSize
        {
            get
            {
                return _XHeaderFontSize;
            }
            set
            {
                _XHeaderFontSize = value;
                Refresh();
            }
        }
        private Brush _XHeaderForeground;
        [Category("表头")]
        [DisplayName("表头前景色")]
        [Description("HeaderForeground")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "HeaderForeground", "表头前景色")]
        public Brush XHeaderForeground
        {
            get
            {
                return _XHeaderForeground;
            }
            set
            {
                _XHeaderForeground = value;
                Refresh();
            }
        }
        private double _XHeaderHeight;
        [Category("表头")]
        [DisplayName("表头高度")]
        [Description("HeaderHeight")]
        //[Editor(typeof(UI.XProperty.Editors.XDoubleEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "HeaderHeight", "表头高度")]
        public double XHeaderHeight
        {
            get
            {
                return _XHeaderHeight;
            }
            set
            {
                _XHeaderHeight = value;
                Refresh();
            }
        }
        private Brush _XRowBorderBrush;
        [Category("行")]
        [DisplayName("行的边框颜色")]
        [Description("RowBorderBrush")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowBorderBrush", "行的边框颜色")]
        public Brush XRowBorderBrush
        {
            get
            {
                return _XRowBorderBrush;
            }
            set
            {
                _XRowBorderBrush = value;
                Refresh();
            }
        }
        private Thickness _XRowBorderThickness;
        [Category("行")]
        [DisplayName("行的边框大小")]
        [Description("RowBorderThickness")]
        //[Editor(typeof(UI.XProperty.Editors.XThicknessEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowBorderThickness", "行的边框大小")]
        public Thickness XRowBorderThickness
        {
            get
            {
                return _XRowBorderThickness;
            }
            set
            {
                _XRowBorderThickness = value;
                Refresh();
            }
        }
        private Brush _XRowBackground;
        [Category("行")]
        [DisplayName("行的背景颜色")]
        [Description("RowBackground")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowBackground", "行的背景颜色")]
        public Brush XRowBackground
        {
            get
            {
                return _XRowBackground;
            }
            set
            {
                _XRowBackground = value;
                Refresh();
            }
        }
        private FontFamily _XRowFont;
        [Category("行")]
        [DisplayName("行的字体")]
        [Description("RowFont")]
        //[Editor(typeof(UI.XProperty.Editors.XFontFamilyEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowFont", "行的字体")]
        public FontFamily XRowFont
        {
            get
            {
                return _XRowFont;
            }
            set
            {
                _XRowFont = value;
                Refresh();
            }
        }
        private FontWeight _XRowFontWeight;
        [Category("行")]
        [DisplayName("行字体粗细")]
        [Description("RowFontWeight")]
        //[Editor(typeof(UI.XProperty.Editors.XFontWeightEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowFontWeight", "行字体粗细")]
        public FontWeight XRowFontWeight
        {
            get
            {
                return _XRowFontWeight;
            }
            set
            {
                _XRowFontWeight = value;
                Refresh();
            }
        }
        private double _XRowFontSize;
        [Category("行")]
        [DisplayName("行的字体大小")]
        [Description("RowFontSize")]
        //[Editor(typeof(UI.XProperty.Editors.XDoubleEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowFontSize", "行的字体大小")]
        public double XRowFontSize
        {
            get
            {
                return _XRowFontSize;
            }
            set
            {
                _XRowFontSize = value;
                Refresh();
            }
        }
        private Brush _XRowForeground;
        [Category("行")]
        [DisplayName("行的前景色")]
        [Description("RowForeground")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowForeground", "行的前景色")]
        public Brush XRowForeground
        {
            get
            {
                return _XRowForeground;
            }
            set
            {
                _XRowForeground = value;
                Refresh();
            }
        }
        private Brush _XOddRowBorderBrush;
        [Category("奇数行")]
        [DisplayName("奇数行的边框颜色")]
        [Description("OddRowBorderBrush")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "OddRowBorderBrush", "奇数行的边框颜色")]
        public Brush XOddRowBorderBrush
        {
            get
            {
                return _XOddRowBorderBrush;
            }
            set
            {
                _XOddRowBorderBrush = value;
                Refresh();
            }
        }
        private Thickness _XOddRowBorderThickness;
        [Category("奇数行")]
        [DisplayName("奇数行的边框大小")]
        [Description("OddRowBorderThickness")]
        //[Editor(typeof(UI.XProperty.Editors.XThicknessEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "OddRowBorderThickness", "奇数行的边框大小")]
        public Thickness XOddRowBorderThickness
        {
            get
            {
                return _XOddRowBorderThickness;
            }
            set
            {
                _XOddRowBorderThickness = value;
                Refresh();
            }
        }
        private Brush _XOddRowBackground;
        [Category("奇数行")]
        [DisplayName("奇数行的背景颜色")]
        [Description("OddRowBackground")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "OddRowBackground", "奇数行的背景颜色")]
        public Brush XOddRowBackground
        {
            get
            {
                return _XOddRowBackground;
            }
            set
            {
                _XOddRowBackground = value;
                Refresh();
            }
        }
        private Brush _XOddRowForeground;
        [Category("奇数行")]
        [DisplayName("奇数行的前景颜色")]
        [Description("OddRowForeground")]
        //[Editor(typeof(UI.XProperty.Editors.XBrushEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "OddRowForeground", "奇数行的前景颜色")]
        public Brush XOddRowForeground
        {
            get
            {
                return _XOddRowForeground;
            }
            set
            {
                _XOddRowForeground = value;
                Refresh();
            }
        }

        private FontFamily _XOddRowFont;
        [Category("奇数行")]
        [DisplayName("奇数行的字体")]
        [Description("OddRowFont")]
        //[Editor(typeof(UI.XProperty.Editors.XFontFamilyEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "OddRowFont", "奇数行的字体")]
        public FontFamily XOddRowFont
        {
            get
            {
                return _XOddRowFont;
            }
            set
            {
                _XOddRowFont = value;
                Refresh();
            }
        }
        private FontWeight _XOddRowFontWeight;
        [Category("奇数行")]
        [DisplayName("奇数行字体粗细")]
        [Description("OddRowFontWeight")]
        //[Editor(typeof(UI.XProperty.Editors.XFontWeightEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "OddRowFontWeight", "奇数行字体粗细")]
        public FontWeight XOddRowFontWeight
        {
            get
            {
                return _XOddRowFontWeight;
            }
            set
            {
                _XOddRowFontWeight = value;
                Refresh();
            }
        }
        private double _XOddRowFontSize;
        [Category("奇数行")]
        [DisplayName("奇数行的字体大小")]
        [Description("OddRowFontSize")]
        //[Editor(typeof(UI.XProperty.Editors.XDoubleEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "OddRowFontSize", "奇数行的字体大小")]
        public double XOddRowFontSize
        {
            get
            {
                return _XOddRowFontSize;
            }
            set
            {
                _XOddRowFontSize = value;
                Refresh();
            }
        }
        private double? _XRowHeight;
        [Category("行")]
        [DisplayName("行高")]
        [Description("RowHeight")]
        //[Editor(typeof(UI.XProperty.Editors.XDoubleEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowHeight", "行高")]
        public double? XRowHeight
        {
            get
            {
                return _XRowHeight;
            }
            set
            {
                _XRowHeight = value;
                Refresh();
            }
        }
        private bool _XIsShowRowBorder;
        [Category("其他")]
        [DisplayName("是否显示边框")]
        [Description("IsShowRowBorder")]
        //[Editor(typeof(UI.XProperty.Editors.XBooleanEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "IsShowRowBorder", "是否显示边框")]
        public bool XIsShowRowBorder
        {
            get
            {
                return _XIsShowRowBorder;
            }
            set
            {
                _XIsShowRowBorder = value;
                Refresh();
            }
        }

        private bool _allowRowLoop = true;
        [Category("其他")]
        [DisplayName("是否执行页面切换")]
        [Description("IsPageLoop")]
        //[Editor(typeof(UI.XProperty.Editors.XBooleanEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "AllowRowLoop", "是否执行页面切换")]
        public bool AllowRowLoop
        {
            get
            {
                return _allowRowLoop;
            }
            set
            {
                _allowRowLoop = value;
            }
        }
        private int _pageRowCount = 15;
        [Category("其他")]
        [DisplayName("每页显示的行数")]
        [Description("PageRowCount")]
        //[Editor(typeof(UI.XProperty.Editors.XIntEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "PageRowCount", "每页显示的行数")]
        public int XPageRowCount
        {
            get
            {
                return _pageRowCount;
            }
            set
            {
                _pageRowCount = value;
                //Refresh();
            }
        }
        private int? _XPageLoopInterval;
        /// <summary>
        /// 页面切换时间
        /// </summary>
        [Category("其他")]
        [DisplayName("页面切换时间")]
        [Description("PageLoopInterval")]
        //[Editor(typeof(UI.XProperty.Editors.XIntEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "PageLoopInterval", "页面切换时间")]
        public int? XPageLoopInterval
        {
            get
            {
                return _XPageLoopInterval;
            }
            set
            {
                _XPageLoopInterval = value;
                Refresh();
            }
        }
        private int? _XPageLoopRowCount;
        [Category("其他")]
        [DisplayName("页面切换行的数量")]
        [Description("PageLoopRowCount")]
        //[Editor(typeof(UI.XProperty.Editors.XIntEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "PageLoopRowCount", "页面切换行的数量")]
        public int? XPageLoopRowCount
        {
            get
            {
                return _XPageLoopRowCount;
            }
            set
            {
                _XPageLoopRowCount = value;
                Refresh();
            }
        }

        private string _XNullValueText;
        [Category("其他")]
        [DisplayName("值为空时显示的文本")]
        [Description("NullValueText")]
        //[Editor(typeof(UI.XProperty.Editors.XStringEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "NullValueText", "值为空时显示的文本")]
        public string XNullValueText
        {
            get
            {
                return _XNullValueText;
            }
            set
            {
                _XNullValueText = value;
                Refresh();
            }
        }

        private string _XAsNullValues;
        /// <summary>
        /// 配置可以视为空文本的值:  "0.0,0,0%,0.0%"
        /// 用逗号间隔，每个当数据的值和定义的片段的值一样时视为null
        /// 默认为"0,0%,0.0"
        /// </summary>        
        [Category("其他")]
        [DisplayName("视为空文本的值")]
        [Description("AsNullValues")]
        //[Editor(typeof(UI.XProperty.Editors.XStringEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "AsNullValues", "视为空文本的值")]
        public string XAsNullValues
        {
            get
            {
                return _XAsNullValues;
            }
            set
            {
                _XAsNullValues = value;
                //Refresh();
            }
        }
        private string _XPageLoopDirection;
        /// <summary>
        /// 数据的更新方向 ，向上或向下，默认是向上
        /// </summary>
        [Category("其他")]
        [DisplayName("数据更新方向")]
        [Description("PageLoopDirection")]
        //[Editor(typeof(UI.XProperty.Editors.XStringEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "PageLoopDirection", "数据更新方向", false)]
        public string XPageLoopDirection
        {
            get
            {
                return _XPageLoopDirection;
            }
            set
            {
                _XPageLoopDirection = value;
                Refresh();
            }
        }
        private double _XRowLoopDuration;
        [Category("其他")]
        [DisplayName("行更新的时间")]
        [Description("RowLoopDuration")]
        //[Editor(typeof(UI.XProperty.Editors.XDoubleEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "RowLoopDuration", "行更新的时间", false)]
        public double XRowLoopDuration
        {
            get
            {
                return _XRowLoopDuration;
            }
            set
            {
                _XRowLoopDuration = value;
                Refresh();
            }
        }
        private bool _XIsAllRowLoop;
        [Category("其他")]
        [DisplayName("是否全部行一起翻动")]
        [Description("IsAllRowLoop")]
        //[Editor(typeof(UI.XProperty.Editors.XBooleanEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "IsAllRowLoop", "是否全部行一起翻动", false)]
        public bool XIsAllRowLoop
        {
            get
            {
                return _XIsAllRowLoop;
            }
            set
            {
                _XIsAllRowLoop = value;
                Refresh();
            }
        }
        private bool _XIsShowWhenNull;
        [Category("其他")]
        [DisplayName("无数据时是否显示行")]
        [Description("IsShowWhenNull")]
        //[Editor(typeof(UI.XProperty.Editors.XBooleanEditor), typeof(UI.XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Other, "IsShowWhenNull", "无数据时是否显示行", false)]
        public bool XIsShowWhenNull
        {
            get
            {
                return _XIsShowWhenNull;
            }
            set
            {
                _XIsShowWhenNull = value;
                Refresh();
            }
        }
        #endregion
    }
}
